package org.zfes.snowier.zbss.xzy.router.file;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.file.model.File;
import org.zfes.snowier.zbss.xzy.biz.file.service.IFileService;
import org.zfes.snowier.core.data.SelectVo;
@Controller("org.zfes.snowier.zbss.xzy.router.file.FileController") 
@RequestMapping("/manger/file")
public class FileController implements BaseController {

	
	@Autowired
	private IFileService fileService;
	
    @RequestMapping(value="/loadFileDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadFileDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  fileService.loadFileDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
    @RequestMapping(value="/loadFile/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadFile(@PathVariable("id")Long id){
		Optional<File> ops = fileService.loadFileById(id);
		return ajaxQuery("file",ops);
    }
	
	
    @RequestMapping(value="/deleteFile/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteFile(@PathVariable("id")Long id){
		fileService.deleteFile(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

    
}